package com.headingdata.random;

import java.util.Random;
import java.util.Scanner;

public class RandomTest2 {
    public static void main(String[] args) {
        //1.随机产生1-100数字作为中奖号码
        Random r = new Random();
        int luckNumber = r.nextInt(100)+1;

        Scanner scan = new Scanner(System.in);

        while (true){
            System.out.println("请输入您选择的数字：");
            int guessNumber = scan.nextInt();
            if (guessNumber > luckNumber){
                System.out.println("您猜测的数据过大！");
            }else if (guessNumber < luckNumber){
                System.out.println("您猜测的数据过小！");
            }else {
                System.out.println("恭喜您，您猜测成功！可以买单了·~~");
                break;
            }
        }
    }
}
